package com.jun.seckill_by_jun.service;

import com.jun.seckill_by_jun.dao.GoodsDao;
import com.jun.seckill_by_jun.domain.Goods;
import com.jun.seckill_by_jun.vo.GoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsService {
    @Autowired
    private GoodsDao goodsDao;

    public List<GoodsVo> listGoodVo(){
        return goodsDao.listGoodsVo();
    }

    public GoodsVo getGoodsVoByGoodsId(long goodsId) {
        return goodsDao.getGoodsByGoodsId(goodsId);
    }

    public boolean reduceStock(GoodsVo goods) {
        Goods g = new Goods();
        g.setId(goods.getId());
        return goodsDao.reduceStock(g);
    }
}
